import { MockMethod } from "vite-plugin-mock";

export const result = {
  errorCode: 0,
  message: "",
  data: [
    {
      id: "9159877732",
      model: "Adam4118",
      spec: null,
      name: "zjr2-167",
      memo: "hello world zp",
      version: null,
      parentId: null,
      address: "8",
      port: "COM7",
      property: {
        trial: "设备特有属性",
        baudRate: "9600",
        dataBits: "8",
        stopBits: "Two",
        parity: "None"
      },
      createTime: "2023-04-17T00:24:37.1970314+08:00",
      isSetup: true
    },
    {
      id: "9652354555",
      model: "Thermocouple",
      spec: "TypeT",
      name: "我的热电偶chnl3",
      memo: "后来添加的",
      version: null,
      parentId: "9159877732",
      address: "3",
      port: "3",
      property: {
        trial: "设备特有属性",
        chlIdx: "3"
      },
      createTime: "2023-04-22T17:12:34.4758122+08:00",
      isSetup: true
    },
    {
      id: "9170345695",
      model: "Thermocouple",
      spec: "TypeT",
      name: "甲字热电偶chnl2",
      memo: "第一个添加的",
      version: null,
      parentId: "9159877732",
      address: "2",
      port: "2",
      property: {
        trial: "设备特有属性",
        chlIdx: "2"
      },
      createTime: "2023-04-17T03:19:05.0266847+08:00",
      isSetup: true
    },
    {
      id: "9837320321",
      model: "Pressductor",
      spec: "",
      name: "第一号压传",
      memo: "货号是SIN-P300-B",
      version: null,
      parentId: "9159877732",
      address: "0",
      port: "0",
      property: {
        trial: "设备特有属性",
        chlIdx: "0",
        rangeMeasure: "MPa",
        rangeFrom: "0.1",
        rangeTo: "20.2",
        displayMeasure: "MPa",
        ratio: "0.01"
      },
      createTime: "2023-04-24T20:35:20.754232+08:00",
      isSetup: true
    },
    {
      id: "9843730955",
      model: "Thermocouple",
      spec: "TypeT",
      name: "我的热电偶chnl3b",
      memo: "后来添加的",
      version: null,
      parentId: "9159877732",
      address: "5",
      port: "5",
      property: {
        trial: "设备特有属性",
        chlIdx: "5"
      },
      createTime: "2023-04-24T22:22:10.7863736+08:00",
      isSetup: true
    }
  ]
};
export default [
  {
    url: "/listDevices",
    method: "get",
    response: () => {
      return result;
    }
  },
  {
    url: "/addDevice",
    method: "post",
    response: ({ body }) => {
      body.createTime = new Date();
      body.id = Math.round(body.createTime.getTime() / 1000);
      result.data.push(body);
      return result;
    }
  }
] as MockMethod[];
